﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace PayrollSystemLibrary.Model
{
    public static class DataAnnotationsValidator
    {
        //Keywords , like object, are predefined reserved identifiers that have special meanings to the compiler. 
        // They cannot be used as identifiers in your program unless they include @ as a prefix
        public static bool TryValidate(object @object, out List<ValidationResult> results)
        {
            var context = new ValidationContext(@object, serviceProvider: null, items: null);
            results = new List<ValidationResult>();
            return Validator.TryValidateObject(
                @object, context, results,
                validateAllProperties: true
                );
        }
    }
}